#if !defined(SM__GAME_H)
#define SM__GAME_H

#include "SDL.h"

class Display;
class Player;
class Scene;
#include "Sprite.h"
#include "Swag.h"
#include <vector>

// Game class to encapsulate the whole game, including tracking
// the time left, eventually the game loop, handling input, etc
class Game 
{
  private:
    Sint32 mTimeLeftInSec;
    Uint32 mStartTimeInMs;

    Display* mpDisplay;
    Scene*   mpScene;
    Player*  mpPlayer;
    Sprite*  mpSwagPenSprite;
    vector<Sprite> mSprites;
    vector<Swag *> mSwaggage;

    XMLNode* mpConfig;

    NodeArray mAllLevels;
    XMLNode* mpCurLevel;

    void Init();
    void InitScene();
    void DrawScene();

    // renders the status area (called from Update())
    void DrawStatus();

    // map edge collision detection & reaction
    int boundsCheck(int x, int y, int &fixedX, int &fixedY);
    int collisionTest(int x1, int y1, int x2, int y2);
    // configuration-related functions and handlers
//    friend void sm_xml_start(void *, const char *, const char **);
//    friend void sm_xml_end(void *, const char *el);
    XMLNode* InitConfig(const char* szConfigFilename);
//    void xmlStart(const char *el, const char **attr);
//    void xmlEnd(const char *el);

  public:
    Game();
    ~Game();

    bool IsGameOver() const { return (mTimeLeftInSec <= 0); }

    // called every game loop 
    void Update(Uint8* keystate);
};

#endif // SM__GAME_H
